{extend name='common/_container'} {block name="content"}
<div class="row">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">
			<div class="ibox-content"> 
				<div class="row row-lg"> 
					<div class="col-sm-12"> 
						<div class="row" id="searchGroup">
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">电话</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="tel" placeholder="电话" />
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">支付订单号</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="pay_order" placeholder="支付订单号" />
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">支付状态</button>
									</div>
									<select class="form-control" id="state">
										<option value="">请选择</option>
										<option value="0">未支付</option>
										<option value="1">已支付</option>
										<option value="2">已完成</option>
										<option value="3">已评价</option>
									</select>
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">状态</button>
									</div>
									<select class="form-control" id="type">
										<option value="">请选择</option>
										<option value="0">待确认</option>
										<option value="1">已确认</option>
										<option value="2">已完成</option>
									</select>
								</div>
							</div>
							<!-- search end -->
							<div class="col-sm-1">
								<button type="button" class="btn btn-success " onclick="CodeGoods.search()" id="">
									<i class="fa fa-search"></i>&nbsp;搜索
								</button>
							</div>
						</div>
						<div class="btn-group-sm" id="CodeGoodsTableToolbar" role="group">
						</div>
						<table id="CodeGoodsTable" data-mobile-responsive="true" data-click-to-select="true">
							<thead><tr><th data-field="selectItem" data-checkbox="true"></th></tr></thead>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	var CodeGoods = {id: "CodeGoodsTable",seItem: null,table: null,layerIndex: -1};

	CodeGoods.initColumn = function () {
 		return [
 			{field: 'selectItem', checkbox: true},
 			{title: '编号', field: 'cl_id', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '用户id', field: 'uid', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '电话', field: 'tel', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '分钟', field: 'minute', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '实际金额', field: 'price', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '订单号', field: 'order_no', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '支付订单号', field: 'pay_order', visible: true, align: 'center', valign: 'middle',sortable: true},
 			{title: '下单时间', field: 'create_time', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.create_timeFormatter},
 			{title: '支付时间', field: 'pay_time', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.pay_timeFormatter},
 			{title: '支付状态', field: 'state', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.stateFormatter},
 			{title: '状态', field: 'type', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.typeFormatter},
 		];
 	};

	CodeGoods.create_timeFormatter = function(value,row,index) {
		if(value){
			return formatDateTime(value,'Y-m-d H:i:s');	
		}
	}

	CodeGoods.pay_timeFormatter = function(value,row,index) {
		if(value){
			return formatDateTime(value,'Y-m-d H:i:s');	
		}
	}

	CodeGoods.stateFormatter = function(value,row,index) {
		if(value !== null){
			var value = value.toString();
			switch(value){
				case '0':
					return '未支付';
				break;
				case '1':
					return '<span class="label label-primary">已支付</span>';
				break;
				case '2':
					return '<span class="label label-success">已完成</span>';
				break;
				case '3':
					return '<span class="label label-info">已评价</span>';
				break;
			}
		}
	}

	CodeGoods.typeFormatter = function(value,row,index) {
		if(value !== null){
			var value = value.toString();
			switch(value){
				case '0':
					return '待确认';
				break;
				case '1':
					return '已确认';
				break;
				case '2':
					return '已完成';
				break;
			}
		}
	}

	CodeGoods.formParams = function() {
		var queryData = {};
		queryData['offset'] = 0;
		queryData['tel'] = $("#tel").val();
		queryData['pay_order'] = $("#pay_order").val();
		queryData['state'] = $("#state").val();
		queryData['type'] = $("#type").val();
		return queryData;
	}

	CodeGoods.check = function () {
		var selected = $('#' + this.id).bootstrapTable('getSelections');
		if(selected.length == 0){
			Feng.info("请先选中表格中的某一记录！");
			return false;
		}else{
			CodeGoods.seItem = selected;
			return true;
		}
	};

	CodeGoods.search = function() {
		CodeGoods.table.refresh({query : CodeGoods.formParams()});
	};

	$(function() {
		var defaultColunms = CodeGoods.initColumn();
		var url = location.search;
		var table = new BSTable(CodeGoods.id, Feng.ctxPath+"/Customer.Lists/index"+url,defaultColunms,20);
		table.setPaginationType("server");
		table.setQueryParams(CodeGoods.formParams());
		CodeGoods.table = table.init();
	});
</script>
{/block}